package woa.linkedlist;

/**
 * 链表工具类
 *
 * @author wangpeng
 */
public class ListNodeUtils {

    public static ListNode createByArray(int[] arr) {
        if (arr.length == 0) {
            return null;
        }
        ListNode head = new ListNode(arr[0]);
        ListNode cur = head;
        for (int i = 1; i < arr.length; i++) {
            cur.next = new ListNode(arr[i]);
            cur = cur.next;
        }

        return head;
    }

    public static void printListNode(ListNode head) {
        while (head != null) {
            System.out.println(head.val);
            head = head.next;
        }
    }

    public static void main(String[] args) {
        ListNode head = createByArray(new int[]{});
        printListNode(head);
    }
}
